Function Reference

_ArrayPush

Add new values without increasing array size.Either by inserting at the end the new value and deleting the first one or vice versa.

#include <Array.au3>
_ArrayPush ( ByRef $avArray, $sValue [, $i_Direction = 0] )

 

Parameters

$avArray Input Array to updated.
$sValue New value to be added.It can be an array too.
$i_Direction Optional: 0 = Leftwise slide of values (default)
  1 = Rightwise slide of values

 

Return Value

On Success - Returns 1
On Failure - 0 if $avArray is not an array.
    -1 if $sValue array size is greater than $avArray size.
              In both cases @error is set to 1.

 

Remarks

This function is used for continuous updates of data in array, where in other cases a vast size of array would be created.It keeps all values inside the array -something like History - ,minus the first one or the last one depending on direction chosen.It is similar to Push command in Assembly.

 

Related

_ArrayPop

 

Example


#include <Array.au3>

 
;First Example

Dim $test[5],$var[2],$b=5
$test[0]=0
$test[1]=1
$test[2]=2
$test[3]=3
$test[4]=4

$var[0]=6
$var[1]=7

_ArrayPush($test,$b)
_ArrayDisplay($test,"ArrayUpdate Test") ; The values now are : 1,2,3,4,5

_ArrayPush($test,$var)
_ArrayDisplay($test,"ArrayUpdate Test") ; The values now are : 3,4,5,6,7

;Second Example(not working)
Dim $Monitor[5],$Messages=""
While 1
    $msg = GUIGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $button
        ;;;;
    EndSelect
_ArrayPush($Monitor,$msg)
WEnd


For $i = 0 to 4
    $Messages&=$monitor[$i] & ","
Next

MsgBox(0,"Monitoring Test"," The last 5 GUI Messages were : " & $Messages)